package com.soup.lab.basic.iso.executor;

import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class KeyPickRunnableFuture<K, V> extends FutureTask<V> implements KeyPickRunnable<K> {

    private final Collection<K> keys;

    public KeyPickRunnableFuture(Callable<V> callable, Collection<K> keys) {
        super(callable);
        this.keys = keys;
    }

    public KeyPickRunnableFuture(KeyPickRunnable<K> runnable, V result) {
        super(runnable, result);
        keys = Collections.unmodifiableCollection(runnable.getKeys());
    }

    @Override
    public Collection<K> getKeys() {
        return keys;
    }

    @Override
    public String toString() {
        return "KeyPickRunnableFuture{" +
                "keys=" + keys +
                "}";
    }
}
